#ifndef GTKMM_EXAMPLE_MYAREA_H
#define GTKMM_EXAMPLE_MYAREA_H

#include <gtkmm.h>
#include <cairomm/context.h>
#include "listview.h"
#include "rectangle.h"


class MyArea : public Gtk::DrawingArea
{
public:

  enum FileType { PNG, PDF, PS};
  MyArea();
  virtual ~MyArea();
  void set_model(const Glib::RefPtr<Gtk::ListStore>&);
  void set_space(Rectangle* );
  void paint();
  void draw(const Cairo::RefPtr<Cairo::Context>& cr);
  void writeFile(std::string filename, FileType t);
  void set_adjustment (Gtk::Adjustment &adj);
  void set_tree_view(const Glib::RefPtr<Gtk::TreeSelection>& t);
  void reset_zoom();

protected:
  //Override default signal handler:
  virtual bool on_eventbox_button_press(GdkEventButton*);
  virtual bool on_eventbox_button_release(GdkEventButton* event);
  virtual bool on_eventbox_scroll(GdkEventScroll* event);
  virtual bool on_expose_event(GdkEventExpose* event);
  virtual bool on_eventbox_pointer_motion(GdkEventMotion* event);
  void change_zoom();

  Glib::RefPtr<Gtk::ListStore> model;
  Rectangle* space;
  Rectangle zoom;

  Gtk::Adjustment *zoom_level;

  ModelColumns m_Columns;

  double x1, x2, y1, y2;
  Gdk::Cursor cur;
  Glib::RefPtr<Gtk::TreeSelection> m_view;
};

#endif // GTKMM_EXAMPLE_MYAREA_H
